package com.wangshuo.webadmin.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wangshuo.webadmin.entity.*;
import com.wangshuo.webadmin.mapper.*;
import com.wangshuo.webadmin.service.LeaseAgreementService;
import com.wangshuo.webadmin.vo.agreement.AgreementQueryVo;
import com.wangshuo.webadmin.vo.agreement.AgreementVo;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

/**
* @author 13326
* @description 针对表【lease_agreement(租约信息表)】的数据库操作Service实现
* @createDate 2025-01-21 16:43:50
*/
@Service
public class LeaseAgreementServiceImpl extends ServiceImpl<LeaseAgreementMapper, LeaseAgreement>
    implements LeaseAgreementService{
    private final LeaseAgreementMapper leaseAgreementMapper;
    private final ApartmentInfoMapper apartmentInfoMapper;
    private final RoomInfoMapper roomInfoMapper;
    private final PaymentTypeMapper paymentTypeMapper;
    private final LeaseTermMapper leaseTermMapper;

    public LeaseAgreementServiceImpl(LeaseAgreementMapper leaseAgreementMapper, ApartmentInfoMapper apartmentInfoMapper, RoomInfoMapper roomInfoMapper, PaymentTypeMapper paymentTypeMapper, LeaseTermMapper leaseTermMapper) {
        this.leaseAgreementMapper = leaseAgreementMapper;
        this.apartmentInfoMapper = apartmentInfoMapper;
        this.roomInfoMapper = roomInfoMapper;
        this.paymentTypeMapper = paymentTypeMapper;
        this.leaseTermMapper = leaseTermMapper;
    }

    @Override
    public IPage<AgreementVo> pageByquery(IPage<AgreementVo> page, AgreementQueryVo queryVo){
        return leaseAgreementMapper.pageByquery(page,queryVo);
    }
    @Override
    public  AgreementVo selectbyid(Long id){
        LeaseAgreement leaseAgreement=leaseAgreementMapper.selectById(id);
        AgreementVo agreementVo=new AgreementVo();
        BeanUtils.copyProperties(leaseAgreement,agreementVo);
ApartmentInfo apartmentInfo=apartmentInfoMapper.selectlistbyid(id);
agreementVo.setApartmentInfo(apartmentInfo);
        RoomInfo roomInfo= roomInfoMapper.selectlistbyid(id);
        agreementVo.setRoomInfo(roomInfo);

        PaymentType paymentType=paymentTypeMapper.selectlistbyid1(id);
        agreementVo.setPaymentType(paymentType);
        LeaseTerm leaseTerm=leaseTermMapper.selectlistbyid1(id);
        agreementVo.setLeaseTerm(leaseTerm);
        return agreementVo;
    }

}




